// pages/studentInformation/graduainforma/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabList: {
      // uname: "李㤾伦",
      // englishname: "李㤾伦",
      // sex: "男",
      // people: "123456789",
      // birthday: "2019-06-12",
      // privance: "广东",
      // qujuenly: "汉",
      // studynum: "123456789",
      // megurys: "体育",
      // zhzface: "团员",
      // Remarks: "无"
    },
    zp: '',
    pageText: {},
    pageList: [],
    titleList: [],
    titleListto: [],
    checkinginformation: '以下个人信息用于制作毕业证书、学位证书及学历、学位电子注册，请认真按要求核对。',
    successsubmit: '以下个人信息用于制作毕业证书、学位证书及学历、学位电子注册，请认真按要求核对。',
    id: '',
    container: '信息提交后不可修改请确认信息无误',
    imgsrc: '../../assets/images/waring.png'
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(options,"这是传了id")
    // this.setData({
    //   id: options.id
    // })
    this.getdataList();
    // this.gettitleList();
  },
  getdataList () {
    const { id } = this.data
    const request = {
      id: this.data.id
    }
    this.setData({
      appMsg: {
        type: 'loading',
        show: true
      }
    })

    wx.$API['studentInformation/getGraduate'](request).then((response) => {
      this.setData({
        appMsg: {
          type: 'loading',
          show: false
        }
      })

      // console.log(response.data[0])


      this.setData({
        // tabList: response.data[0],
        // zp: response.data[0].zp
        pageText: response.data.pageText[0],
        pageList: response.data.params,
        tabList: response.data.notHied,
        id: response.data.notHied.id
      })

      // this.setData({
      //   id: response.data[0].id
      // })

      // const data = response.data
      // const dataLength = response.data.length

    }).catch((error) => {
      console.log(error, "返回错误信息")
      // wx.showToast({
      //   title: "您不是毕业生",
      //   icon: "none",
      //   duration: 2000
      // })
      // setTimeout(() => {
      //   wx.navigateBack({
      //     delta: 1
      //   })
      // }, 2000)



    })
  },
  // gettitleList () {
  //   this.setData({
  //     appMsg: {
  //       type: 'loading',
  //       show: true
  //     }
  //   })

  //   const { } = this.data
  //   const request = {

  //   }

  //   wx.$API['studentInformation/getGraduatePageInfo'](request).then((response) => {
  //     this.setData({
  //       appMsg: {
  //         type: 'loading',
  //         show: false
  //       }
  //     })
  //     this.setData({
  //       titleList: response.data.params,
  //       pageText: response.data.pageText[0]
  //     })

  //   }).catch((error) => {

  //   })
  // },


  clickimg () {
    wx.previewImage({
      current: this.data.zp,
      urls: [this.data.zp], // 需要预览的图片http链接列表
      success: function (res) {
        console.log(res, "回调成功的函数");
      },
      fail: function (res) {
        console.log(res, "回调失败的函数");

      },
    })
  },

  getoptiondata () {

    wx.showLoading({
      title: '加载中'
    })


    for (const key in this.data.tabList) {
      var arraylist = [];
      for (const element of this.data.titleList) {
        if (key == element.param) {
          console.log(element.param, element.param);
          // console.log(this.data.tabList[key]);
          arraylist = this.data.tabList[key];
          element.value = arraylist;
          break

        }
      }
    }

    console.log(this.data.titleList);
    this.setData({
      titleListto: this.data.titleList
    })

    setTimeout(() => {
      wx.hideLoading();
    }, 2500);





  },


  //确定事件
  _cancelEvent () {

    const { id } = this.data
    const request = {
      id: this.data.id
    }
    console.log(request, "这是id")
    this.setData({
      appMsg: {
        type: 'loading',
        show: true
      }
    })
    wx.$API['studentInformation/ChangeGraduateCheck'](request).then((response) => {
      this.setData({
        appMsg: {
          type: 'loading',
          show: false
        }
      })
      console.log(response, 99999)
      this.dialog.hideDialog();
      wx.navigateTo({
        url: '../../studentInformation/successfulapplication/index?id=' + this.data.id
      })

    }).catch((error) => {
      console.log("返回异常处理")
      wx.showToast({
        title: error,
        icon: "none"
      })
      this.dialog.hideDialog();
    })
  },
  //取消事件
  _confirmEvent () {
    console.log('你点击了确定');
    this.dialog.hideDialog();


  },
  editinformation () {
    console.log(this.data.tabList.id)
    wx.navigateTo({
      url: '../../studentInformation/editinformation/index?id=' + this.data.tabList.id
    })
  },
  disabled () {
    wx.switchTab({
      url: "../../home/index"
    })
  },
  confirmnothing () {
    this.dialog.showDialog();

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    //获得dialog组件
    this.dialog = this.selectComponent("#dialog");
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})